<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Migrate</title>
<meta name="keywords" content="">
<meta name="description" content="">
<link rel="shortcut icon" href="/favicon.ico">
<include file="index@include/bootstrap/css"/>
<include file="index@include/font-awesome/css"/>
<link href="/static/css/migrate/animate.min.css" rel="stylesheet">
<link href="/static/css/migrate/style.min862f.css?v=4.1.0" rel="stylesheet">
<include file="index@include/bootstrap-table/css"/>
<include file="index@include/bootstrap-editable/css"/>
<style type="text/css">

    html, body {
        font-size: 14px;
    }

    .ms-controller {
        display: none;
    }

    .breadcrumb li a {
        color: #0000cc;
    }

    .breadcrumb .active {
        color: green;
    }

</style>
<!--[if lt IE 9]>
<meta http-equiv="refresh" content="0;ie.html"/>
<![endif]-->
<include file="index@include/jquery/js"/>
<include file="index@include/bootstrap/js"/>
<include file="index@include/avalon/js"/>
<include file="index@include/bootstrap-editable/js"/>
<include file="index@include/bootstrap-table/js"/>
<include file="index@include/bootstrap-table/js-zh-cn"/>
<include file="index@include/bootstrap-table/js-editable"/>
<include file="index@include/bootstrap-suggest/js"/>
<include file="index@include/layer/js"/>
<include file="index@include/ace/js"/>
<include file="index@include/moment/js"/>
<include file="index@include/moment/js-zh-cn"/>
<include file="index@include/pace/js"/>
<include file="index@include/jquery-slim-scroll/js"/>
<include file="index@include/metis-menu/js"/>
<script src="/static/js/common.js"></script>
<script src="/static/js/hplus.min.js"></script>
<script src="/static/js/contabs.min.js"></script>
<script type="text/javascript">
    /**
     * token值
     * @type {string}
     */
    var token = jCommon.cookieGet('token');

    /**
     * ajax完成回调函数
     * @param XMLHttpRequest
     * @param textStatus
     */
    var ajax_complete_call_back = function (XMLHttpRequest, textStatus) {
    };

    //重写ajax方法
    (function ($) {
        // 备份jquery的ajax方法
        var _ajax = $.ajax;
        // 重写ajax方法，先判断登录在执行success函数
        $.ajax = function (opt) {
            var _success = opt && opt.success || function (a, b) {
            };
            var _opt = $.extend(opt, {
                success: function (data, textStatus) {
                    if (data.status === -1) {
                        //提醒消息
                        layer.msg(data.message, function () {
                            //关闭后的操作
                        });
                    } else if (data.status === -2) {
                        //session超时
                        window.location.href = '{:url("index/index")}';
                    } else {
                        //执行原先请求
                        _success(data, textStatus);
                    }
                }
            });
            //为空情况判断
            if (jCommon.empty(_opt.data)) {
                _opt.data = {};
            }
            //自动拼接token值
            if (!_opt.data.hasOwnProperty('token') && !jCommon.empty(token)) {
                _opt.data.token = token;
            }
            //回调函数
            _opt.complete = function (XMLHttpRequest, textStatus) {
                ajax_complete_call_back(XMLHttpRequest, textStatus);
            };
            return _ajax(_opt);
        };
    })(jQuery);

    var pendingRequests = {};
    jQuery.ajaxPrefilter(function (options, originalOptions, jqXHR) {
        var key = options.url;
        console.log(key);
        if (!pendingRequests[key]) {
            pendingRequests[key] = jqXHR;
        } else {
            //jqXHR.abort(); //放弃后触发的提交
            pendingRequests[key].abort(); // 放弃先触发的提交
        }
        var complete = options.complete;
        options.complete = function (jqXHR, textStatus) {
            pendingRequests[key] = null;
            if (jQuery.isFunction(complete)) {
                complete.apply(this, arguments);
            }
        };
    });

    //设置不缓存数据
    $.ajaxSetup({
        cache: false
    });

    //校验
    if (['Index/index'].indexOf("{:request()->controller().'/'.request()->action()}") === -1) {
        if (jCommon.empty(token)) {
            //跳转至首页
            window.location.href = '{:url("index/index")}';
        }
    }

</script>